package com.stm.equipmentMonitor.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.stm.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stm.equipmentMonitor.mapper.EquipmenthisMapper;
import com.stm.equipmentMonitor.domain.Equipmenthis;
import com.stm.equipmentMonitor.service.IEquipmenthisService;
import com.stm.common.core.text.Convert;

/**
 * 历史数据 服务层实现
 * 
 * @author wyc
 * @date 2019-04-23
 */
@Service
public class EquipmenthisServiceImpl implements IEquipmenthisService 
{
	@Autowired
	private EquipmenthisMapper equipmenthisMapper;

	/**
     * 查询历史数据信息
     * 
     * @param id 历史数据ID
     * @return 历史数据信息
     */
    @Override
	public Equipmenthis selectEquipmenthisById(String id)
	{
	    return equipmenthisMapper.selectEquipmenthisById(id);
	}
	
	/**
     * 查询历史数据列表
     * 
     * @param equipmenthis 历史数据信息
     * @return 历史数据集合
     */
	@Override
	public List<Equipmenthis> selectEquipmenthisList(Equipmenthis equipmenthis)
	{
	    return equipmenthisMapper.selectEquipmenthisList(equipmenthis);
	}
	
    /**
     * 新增历史数据
     * 
     * @param equipmenthis 历史数据信息
     * @return 结果
     */
	@Override
	public int insertEquipmenthis(Equipmenthis equipmenthis)
	{
	    return equipmenthisMapper.insertEquipmenthis(equipmenthis);
	}
	
	/**
     * 修改历史数据
     * 
     * @param equipmenthis 历史数据信息
     * @return 结果
     */
	@Override
	public int updateEquipmenthis(Equipmenthis equipmenthis)
	{
	    return equipmenthisMapper.updateEquipmenthis(equipmenthis);
	}

	/**
     * 删除历史数据对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteEquipmenthisByIds(String ids)
	{
		return equipmenthisMapper.deleteEquipmenthisByIds(Convert.toStrArray(ids));
	}



	@Override
	public List<Map<String, Object>> getChartData(Equipmenthis equipmenthis) {
		List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
		List<Equipmenthis> list1 = equipmenthisMapper.selectEquipmenthisList(equipmenthis);

		for (Equipmenthis equipmenthis1 : list1) {
			Map<String,Object> resultMap = new HashMap<String,Object>();// 返回值

			resultMap.put("equipmenthisId", equipmenthis1.getId());
			resultMap.put("equipmenthisEquipId", equipmenthis1.getEquipID());
			resultMap.put("equipmenthisEquipName", equipmenthis1.getEquipmentName());
			resultMap.put("equipmenthisWd", equipmenthis1.getWd());
			resultMap.put("equipmenthisSd", equipmenthis1.getSd());
			resultMap.put("equipmenthisDate", equipmenthis1.getDate());
			resultList.add(resultMap);
		}

		return resultList;
	}
	
}
